package gene.android.accountingpro.equations;

import gene.android.accountingpro.finals.EquationNames;
import gene.android.accountingpro.finals.FieldList;

import java.util.ArrayList;
import java.util.List;

public class NetProfitOnSalesRatio extends Equation {
	
	private double net_income;
	private double net_sales;
	
	public NetProfitOnSalesRatio(){}
	
	public NetProfitOnSalesRatio( double netIncome, double netSales )
	{
		this.net_income = netIncome;
		this.net_sales = netSales;
		value = ( net_income / net_sales );
	}

	@Override
	public String getEquationName() {
		return EquationNames.NET_PROFIT_ON_SALES_RATIO;
	}

	@Override
	public List<String> getRequiredFields() {
		List<String> requiredFields = new ArrayList<String>();
		requiredFields.add( FieldList.NET_INCOME );
		requiredFields.add( FieldList.NET_SALES );
		return requiredFields;
	}

	@Override
	public void setValues(double[] values) {
		net_income = values[0];
		net_sales = values[1];
		solve();
	}

	@Override
	public String getSolvedEquationString() {
		return "( " + net_income +" / " + net_sales +") = " + value;
	}

	@Override
	public String getEquationString() {
		return "( " + FieldList.NET_INCOME +" / " + FieldList.NET_SALES +")";
	}

	@Override
	public void solve() {
		value = ( net_income / net_sales );	
	}

}
